package lex.swing.outline;

import org.netbeans.swing.outline.RowModel;

public abstract class AbstractRowModel implements RowModel
{
	/**
	 * Returns <code>Object.class</code> regardless of <code>column</code>.
	 * 
	 * @param column
	 *        the column being queried
	 * @return the Object.class
	 */
	@Override
	public Class<?> getColumnClass( int column )
	{
		return Object.class;
	}

	/**
	 * Returns a default name for the column using spreadsheet conventions: A,
	 * B, C, ... Z, AA, AB, etc. If <code>column</code> cannot be found, returns
	 * an empty string.
	 * 
	 * @param column
	 *        the column being queried
	 * @return a string containing the default name of <code>column</code>
	 */
	@Override
	public String getColumnName( int column )
	{
		StringBuilder result = new StringBuilder();
		for( ; column >= 0; column = column / 26 - 1 )
			result.append( (char) ((char) (column % 26) + 'A') );
		result.reverse();
		return result.toString();
	}

	/**
	 * Returns false. This is the default implementation for all cells.
	 * 
	 * @param node
	 *        the bode being queried
	 * @param column
	 *        the column being queried
	 * @return false
	 */
	@Override
	public boolean isCellEditable( Object node, int column )
	{
		return false;
	}

	/**
	 * This empty implementation is provided so users don't have to implement
	 * this method if their data model is not editable.
	 * 
	 * @param value
	 *        value to assign to cell
	 * @param node
	 *        row of cell
	 * @param column
	 *        column of cell
	 */
	@Override
	public void setValueFor( Object node, int column, Object value )
	{}
}
